<?php


namespace app\admin\model;


use think\Model;

/**
 * Class HtnsOrder
 * @package app\admin\model
 * @desc 海淘女神-订单状态日志表
 */
class HtnsOrderStatus extends Model
{
    protected $connection = 'htns';
    protected $table = 'eb_store_order_status';

    public $type = [
        'pay_success'    => '用户付款成功',
        'delivery_goods' => '发货',
        'take_delivery'  => '收货',
    ];

    // 获取订单状态记录
    public function getRow($oid, $type = '')
    {
        $res          = [];
        $where['oid'] = $oid;
        if ($type) {
            $where['change_type'] = $type;
        }
        $row = self::where($where)->find();
        if ($row) {
            $row['change_time'] = $row['change_time'] ? date('Y-m-d H:i:s', $row['change_time']) : 0;
            $res                = $row;
        }
        return $res;
    }
}